package com.wh.shiroswagger.service;

import com.wh.shiroswagger.exception.BusinessException;
import com.wh.shiroswagger.pojo.User;
import com.wh.shiroswagger.result.ResponseCodeMsg;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @Auther: HuiEr
 * @Date: 2020/3/5 21:05
 * @Description
 */
@Service
public class UserService {

    public User login(User user){
        User exUser = new User(1, "wang", "hui", "hhhh", new Date());
        if (!user.getUsername().equals(exUser.getUsername())){
            throw new BusinessException(ResponseCodeMsg.USERNAME_UNKONWED.getCode(),ResponseCodeMsg.USERNAME_UNKONWED.getMsg());
        }
        if(!user.getPassword().equals(exUser.getPassword())){
            throw new BusinessException(ResponseCodeMsg.PASSWORD_INCORRECT.getCode(),ResponseCodeMsg.PASSWORD_INCORRECT.getMsg());
        }
        exUser.setPassword("");
        return exUser;
    }

    public List<User> findUserList(){
        ArrayList<User> users = new ArrayList<>();
        users.add(new User(1,"wang","hui","hhhh",new Date()));
        users.add(new User(2,"hui","wang","bbb",new Date()));
        return users;
    }
    public boolean tokenExistOrNot(String token){
        if(token.equals("hhhh")){
            return true;
        }
        return false;
    }
}
